package cn.wegoteam.shop.po;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Transient;

import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.Table;

import cn.wegoteam.shop.cache.Cache;
import cn.wegoteam.shop.util.Const;
import cn.wegoteam.shop.util.MyString;

/**
 * Staticdata entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "staticdata", catalog = "shop")
public class Staticdata  extends BasePo implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = 2469432855815594938L;
	private Integer id;
	private String code;// 编号
	private String pcode;// 父编号 表中添加了外键，指向
	private String value;// 值
	private String name;// 显示的名字
	private String description;// 备注
	private String link;// 链接
	private Integer flag;// 标志位，
	private Integer order;// 是否排序
	private String type;//类型，多个static拥有 不同的fcode，但是可能属于同一类
	private String img;//不映射表，图片
	
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "code", length = 15,nullable = false)
	public String getCode() {
		return this.code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	@Column(name = "pcode", length = 15)
	public String getPcode() {
		return this.pcode;
	}

	public void setPcode(String pcode) {
		this.pcode = pcode;
	}

	@Column(name = "value", length = 100)
	public String getValue() {
		return this.value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	@Column(name = "name", length = 50)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}
	@Column(name = "type", length = 25)
	public String getType() {
		return this.type;
	}

	public void setType(String type) {
		this.type = type;
	}
	
	@Column(name = "description", length = 100)
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "link", length = 100)
	public String getLink() {
		return this.link;
	}

	public void setLink(String link) {
		this.link = link;
		if(!MyString.isEmpty(link)&&Cache.getSetting(Const.ALIYUNOSSURL)!=null)
			this.img = "<img src=\""+Cache.getSetting(Const.ALIYUNOSSURL).getValue()+link+"\" />";
	}

	@Column(name = "flag", insertable = false, nullable = false)
	public Integer getFlag() {
		return this.flag;
	}

	public void setFlag(Integer flag) {
		this.flag = flag;
	}

	@Column(name = "order_list")
	public Integer getOrder() {
		return this.order;
	}

	public void setOrder(Integer order) {
		this.order = order;
	}
	@Transient
	public String getImg() {
		if(img==null)
			return name;
		return img;
	}

}